package com.changy.ai_tutor_for_dm.controller;

import com.changy.ai_tutor_for_dm.context.UserContext;
import com.changy.ai_tutor_for_dm.result.Result;
import com.changy.ai_tutor_for_dm.service.ClassesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.changy.ai_tutor_for_dm.entity.Classes;

import java.util.List;

@Slf4j
@RestController
public class ClassesController {

    @Autowired private ClassesService classesService;

    @PostMapping("/Classes")
    public Result createClass(@RequestBody Classes classes) {
        classesService.createClass(classes);
        return Result.success();
    }

    @GetMapping("/Classes")
    public Result getClasses() {
        List<Classes> classesList = classesService.getClasses(UserContext.getCardId());
        return Result.success(classesList);
    }

}
